package com.salesmanager.core.business.product;

import com.salesmanager.core.business.common.model.audit.AuditListener;
import com.salesmanager.core.business.common.model.audit.AuditSection;
import com.salesmanager.core.business.common.model.audit.Auditable;
import com.salesmanager.core.business.generic.model.SalesManagerEntity;

import javax.persistence.*;
import java.io.InputStream;
import java.util.Date;

/**
 * Created by LiuTong on 2017/11/21.
 */
@Entity
@EntityListeners(value = AuditListener.class)
@Table(name = "PRODUCT",uniqueConstraints = {
        @UniqueConstraint(columnNames = {"PRODUCT_CODE"})
})
public class Product extends SalesManagerEntity<Long,Product> implements Auditable {

    @Id
    @Column(name = "PRODUCT_ID", unique=true, nullable=false)
    @TableGenerator(name = "TABLE_GEN", table = "SM_SEQUENCER", pkColumnName = "SEQ_NAME", valueColumnName = "SEQ_COUNT",
            pkColumnValue = "PRODUCT_NEXT_VAL",initialValue = 100000, allocationSize = 1)
    @GeneratedValue(strategy = GenerationType.TABLE, generator = "TABLE_GEN")
    private Long id;

    //id, code , name , startTime, endTime, desc，picture(阿里云的oss存储)，count
    @Column(name = "PRODUCT_CODE",columnDefinition = "VARCHAR(10) COMMENT '商品编码'")
    private String productCode;

    @Column(name = "PRODUCT_NAME",columnDefinition = "VARCHAR(10) COMMENT '商品名称'")
    private String productName;

    @Column(name = "START_TIME",columnDefinition = "VARCHAR(30) COMMENT '开始时间'")
    private Date startTime;

    @Column(name = "END_TIME",columnDefinition = "VARCHAR(30) COMMENT '结束时间'")
    private Date endTime;

    @Column(name = "PRODUCT_DESC",columnDefinition = "VARCHAR(10) COMMENT '商品描述'")
    private String productDesc;

    @Column(name = "IMAG_NAME",columnDefinition = "VARCHAR(10) COMMENT '图片名称'")
    private String imagName;

    @Column(name = "COUNT",columnDefinition = "VARCHAR(10) COMMENT '库存'")
    private Integer count;

    @Column(name = "STATUS",columnDefinition = "INT(1) COMMENT '状态 0:无效 1:有效'")
    private Integer status = 1;

    @Transient
    private InputStream imagInputStream;


    public String getProductCode() {
        return productCode;
    }

    public void setProductCode(String productCode) {
        this.productCode = productCode;
    }

    public String getProductName() {
        return productName;
    }

    public void setProductName(String productName) {
        this.productName = productName;
    }

    public Date getStartTime() {
        return startTime;
    }

    public void setStartTime(Date startTime) {
        this.startTime = startTime;
    }

    public Date getEndTime() {
        return endTime;
    }

    public void setEndTime(Date endTime) {
        this.endTime = endTime;
    }

    public String getProductDesc() {
        return productDesc;
    }

    public void setProductDesc(String productDesc) {
        this.productDesc = productDesc;
    }

    public String getImagName() {
        return imagName;
    }

    public void setImagName(String imagName) {
        this.imagName = imagName;
    }

    public Integer getCount() {
        return count;
    }

    public void setCount(Integer count) {
        this.count = count;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public InputStream getImagInputStream() {
        return imagInputStream;
    }

    public void setImagInputStream(InputStream imagInputStream) {
        this.imagInputStream = imagInputStream;
    }

    @Override
    public AuditSection getAuditSection() {
        return null;
    }

    @Override
    public void setAuditSection(AuditSection audit) {

    }

    @Override
    public Long getId() {
        return id;
    }

    @Override
    public void setId(Long id) {
        this.id = id;
    }
}
